#ifndef FILE_MANAGER_H
#define FILE_MANAGER_H

#include <VFS.h>
#include <DataSource.h>

#define MAX_FILES	16

class FileManager{
	DataSource	*dss[MAX_FILES];
	uint32		dsdbm;
	public:
		FileManager(){
			dsdbm = 0;
			uint32 i;
			for(i = 0; i < MAX_FILES; ++i){
				dss[i] = NULL;
			} 
		}
		FileManager(const FileManager &fm){
			dsdbm = fm.dsdbm;
			uint32 i;
			for(i = 0; i < MAX_FILES; ++i){
				dss[i] = fm.dss[i];
			}
		}
		inline DataSource * getDataSource(uint32 dsd){
			return dss[dsd];
		}
		int32 fopen(char *fname){
			DataSource *ds = vfs->open(fname);
			if(!ds) return -1;
			uint32 dsid = getDSId();
			dss[dsid] = ds;
			return dsid;
		}
		uint32 fread(uint32 dsd, char *buf, size_t sz, int32 offset = -1){
			uint32 rbt = 0;
			DataSource *ds = dss[dsd];
			if(!ds) return 0;
			rbt = ds->read(buf, sz, offset);
			kprintf("DS: %X, RBT: %i", ds, rbt);
		}
		
	private:
		uint32 getDSId(){
			return 1;
		}	
};

#endif /* FILE_MANAGER_H */

